In [ ]:
# %pip install -q dimstack
import plotly
plotly.offline.init_notebook_mode()

# disable logging
import logging
logging.getLogger().disabled = True

In [ ]:
import dimstack as ds
import numpy as np
ds.display.mode("df")

m1 = ds.BasicDimension(
    nom=2.565/2,
    tol=ds.tol.SymmetricBilateral(0.05/2),
    name="Datum C Slot Size",
)
m2 = ds.BasicDimension(
    nom=0.7/2,
    tol=ds.tol.SymmetricBilateral(0.07/2),
    name="Datum C Slot Length",
)
m3 = ds.BasicDimension(
    nom=-np.sqrt(45.05**2 + 39.8**2),
    # tol=ds.tol.SymmetricBilateral(np.sqrt(0.3**2 + 0.27**2)),
    tol=ds.tol.SymmetricBilateral(np.sqrt(0.46**2 + 0.4**2)),
    name="Datum C Slot Location",
    desc="Relative to Datum B",
)
m4 = ds.BasicDimension(
    nom=3.065/2,
    tol=ds.tol.SymmetricBilateral(0.05/2),
    name="Datum B Hole Size",
)
m5 = ds.BasicDimension(
    nom=-2.99/2,
    tol=ds.tol.SymmetricBilateral(0.03/2),
    name="Datum B Pin Size",
)
m6 = ds.BasicDimension(
    nom=np.sqrt(45.05**2 + 39.8**2),
    tol=ds.tol.SymmetricBilateral(0.08/2),
    name="Datum C Pin Position",
    desc="Relative to Datum B Pin",
)
m7 = ds.BasicDimension(
    nom=-2.49/2,
    tol=ds.tol.SymmetricBilateral(0.03/2),
    name="Datum C Pin Size",
)
items = [m1, m2, m3, m4, m5, m6, m7]

stack = ds.Stack(title="Datum C Pin-Slot Gap", items=items)
stack
Out[ ]:
Stack: Datum C Pin-Slot Gap
ID Name Description dir Nom. Tol. Sen. Relative Bounds Distribution Process Sigma k C_p C_pk μ σ μ_eff σ_eff Yield Probability Reject PPM
344 Datum C Slot Size Dimension + 1.2825 ± 0.025 1 [1.2575, 1.3075] Uniform
345 Datum C Slot Length Dimension + 0.35 ± 0.035 1 [0.315, 0.385] Uniform
346 Datum C Slot Location Relative to Datum B - 60.11275 ± 0.60959 1 [59.50316, 60.72234] Uniform
347 Datum B Hole Size Dimension + 1.5325 ± 0.025 1 [1.5075, 1.5575] Uniform
348 Datum B Pin Size Dimension - 1.495 ± 0.015 1 [1.48, 1.51] Uniform
349 Datum C Pin Position Relative to Datum B Pin + 60.11275 ± 0.04 1 [60.07275, 60.15275] Uniform
350 Datum C Pin Size Dimension - 1.245 ± 0.015 1 [1.23, 1.26] Uniform
In [ ]:
ds.plot.StackPlot().add(stack).show()
In [ ]:
display(stack.WC)
Dimension: Datum C Pin-Slot Gap - WC Analysis -
ID Name Description dir Nom. Tol. Sen. Relative Bounds Distribution
392 Datum C Pin-Slot Gap - WC Analysis + 0.425 ± 0.76459 1 [-0.33959, 1.18959] Uniform

Since the left side of the slot is our 0 point, we want the left size of the pin to be in the positive direction, or the bounds of the entire tolerance stack to be greater than zero.

At worst-case, the lower bound is negative, meaning the pin would not fit in the slot.

What if we don't need it to fit every time, just pretty dang close to almost every time...

In [ ]:
display(stack.RSS)
display(stack.SixSigma(at=1))
display(stack.SixSigma(at=2))
display(stack.SixSigma(at=4.5))
Dimension: Datum C Pin-Slot Gap - RSS Analysis - (assuming inputs with Normal Distribution & ± 3σ)
ID Name Description dir Nom. Tol. Sen. Relative Bounds Distribution Process Sigma k C_p C_pk μ σ μ_eff σ_eff Yield Probability Reject PPM
520 Datum C Pin-Slot Gap - RSS Analysis (assuming inputs with Normal Distribution & ± 3σ) + 0.425 ± 0.61329 1 [-0.18829, 1.03829] Normal ± 3σ 0 1.0 1.0 0.425 0.20443 0.425 0.20443 99.73002039 2699.8
Dimension: Datum C Pin-Slot Gap - '6 Sigma' Analysis - (assuming inputs with Normal Distribution)
ID Name Description dir Nom. Tol. Sen. Relative Bounds Distribution Process Sigma k C_p C_pk μ σ μ_eff σ_eff Yield Probability Reject PPM
528 Datum C Pin-Slot Gap - '6 Sigma' Analysis (assuming inputs with Normal Distribution) + 0.425 ± 0.20443 1 [0.22057, 0.62943] Normal ± 1σ 0 0.33333 0.33333 0.425 0.20443 0.425 0.20443 68.26894921 317310.51
Dimension: Datum C Pin-Slot Gap - '6 Sigma' Analysis - (assuming inputs with Normal Distribution)
ID Name Description dir Nom. Tol. Sen. Relative Bounds Distribution Process Sigma k C_p C_pk μ σ μ_eff σ_eff Yield Probability Reject PPM
536 Datum C Pin-Slot Gap - '6 Sigma' Analysis (assuming inputs with Normal Distribution) + 0.425 ± 0.40886 1 [0.01614, 0.83386] Normal ± 2σ 0 0.66667 0.66667 0.425 0.20443 0.425 0.20443 95.44997361 45500.26
Dimension: Datum C Pin-Slot Gap - '6 Sigma' Analysis - (assuming inputs with Normal Distribution)
ID Name Description dir Nom. Tol. Sen. Relative Bounds Distribution Process Sigma k C_p C_pk μ σ μ_eff σ_eff Yield Probability Reject PPM
544 Datum C Pin-Slot Gap - '6 Sigma' Analysis (assuming inputs with Normal Distribution) + 0.425 ± 0.91994 1 [-0.49494, 1.34494] Normal ± 4.5σ 0 1.5 1.5 0.425 0.20443 0.425 0.20443 99.99932047 6.8

Let say we design the slot to +/-1sigma, the part has a (100%-68%=) 32% chance of not being able to fit in the mounting hardware. Thats not very good. But the bound is pretty far from our limits (limit > 0).

If look at +/-2sigma, the lower bounds is barely in the positive region, this is our process capability. Therefore, the current slot length will only fit 95% of the time.

If we wanted to target W.C, RSS, +/-3sigma, or +/-4.5sigma, we would have to rework the dimensions to keep the bounds within the positive region for those capabilities

In [ ]:
spec = ds.Spec("stack spec", "", dim=stack.SixSigma(at=2), LL=0.0, UL=99)
spec
Out[ ]:
Spec: stack spec
Name Description Dimension Spec. Limits Median k C_p C_pk Yield Probability Reject PPM
stack spec 512: Datum C Pin-Slot Gap - '6 Sigma' Analysis (assuming inputs with Normal Distribution) +0.425 ± 0.40886 @ ± 2σ & k=0 [0.0, 99] 49.5 0.99141 80.71218 0.69298 100 0